package top.z.work.framework.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 业务逻辑异常
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public final class ServiceException extends RuntimeException {

    // 业务错误码
    private Integer code;
    // 错误提示
    private String  message;

    public ServiceException(ErrorCode errorCode) {
        this.code = errorCode.code();
        this.message = errorCode.message();
    }

    public ServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public String getMessage() {
        return message;
    }

}
